<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.ParseException" %>
<%@ page import="org.springframework.web.context.request.ServletRequestAttributes" %>
<%@ page import="org.springframework.web.context.request.RequestContextHolder" %>
<%@ page import="cn.ecut.model.Contract" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Marvel</title>
    <!-- Bootstrap Styles-->
    <link rel="stylesheet" href="../../static/bootstrap/css/bootstrap.css"/>
    <!-- FontAwesome Styles-->
    <link rel="stylesheet" href="../../static/font-awesome-4.7.0/css/font-awesome.css"/>
    <link rel="stylesheet" href="../../static/font-awesome-4.7.0/css/custom-styles.css"/>
    <link rel="stylesheet" href="../../static/css/style_x.css">
    <!-- Bootstrap Js-->
    <script src="../../static/bootstrap/jquery-3.5.1.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.14.6/umd/popper.js"></script>
    <script src="../../static/bootstrap/js/bootstrap.min.js"></script>
    <style>
        .btn:focus {
            border-style: none;
        }

        .tdbg {
            background-color: darkcyan;
            color: white;
        }
    </style>
</head>
<body onload="show();">
<div class="row">
    <div class="col-2 ">
        <div id="wrapper">
            <nav class="top-navbar">
                <div class="navbar-header">
                    <a href="../../pages/user/userIndex.jsp">
                        <strong class="navbar-brand">住户功能菜单</strong>
                    </a>
                </div>
            </nav>
        </div>
        <nav class="navbar-side" role="navigation">
            <div class="sidebar-collapse">
                <ul class="nav" id="main-menu">
                    <li>
                        <a href="../../pages/user/Rental_center.jsp"><i class="fa fa-dashboard"></i> 租赁中心</a>
                    </li>
                    <li>
                        <a href="../../pages/user/Report_repair.jsp"><i class="fa fa-desktop"></i> 报事报修</a>
                    </li>
                    <li class="active-menu">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
                             class="bi bi-caret-right" viewBox="0 0 16 16">
                            <path fill-rule="evenodd"
                                  d="M6 12.796L11.481 8 6 3.204v9.592zm.659.753l5.48-4.796a1 1 0 0 0 0-1.506L6.66 2.451C6.011 1.885 5 2.345 5 3.204v9.592a1 1 0 0 0 1.659.753z"/>
                        </svg>
                        <a href="../../pages/user/getContract.jsp"><i class="fa fa-bar-chart-o"></i> 结算中心</a>
                    </li>
                    <li>
                        <a href="../../pages/user/Public_weekly.jsp"><i class="fa fa-qrcode"></i> 公共周刊</a>
                    </li>
                    <li>
                        <a href="../../pages/user/Party_building_activities.jsp"><i class="fa fa-history" aria-hidden="true"></i>党建活动</a>
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="col-10" style="background: #fff; margin-top: 60px; min-height: 600px;">
        <c:if test="${empty sessionScope.contract}&&${empty sessionScope.repair}">
            <div style="display: block; height: 558px;" id="empty">
                <h3>您没有费用清单</h3>
            </div>
        </c:if>
        <c:if test="${not empty sessionScope.contract}">
            <!-- 费用清单  -->
            <div style="display: block;margin-bottom: 50px;" id="costList">
                <table class="table table-bordered table-hover">
                    <h4>住宿费用清单</h4>
                    <tr>
                        <td class="tdbg">虚拟合同号</td>
                        <td>${sessionScope.contract.contract_num}</td>
                    </tr>
                    <tr>
                        <td class="tdbg">支行部门</td>
                        <td>${sessionScope.contract.sub_branch}</td>
                    </tr>
                    <tr>
                        <td class="tdbg">甲方名称</td>
                        <td>${sessionScope.contract.party_a}</td>
                    </tr>
                    <tr>
                        <td class="tdbg">乙方名称</td>
                        <td>${sessionScope.contract.party_b}</td>
                    </tr>
                    <tr>
                        <td class="tdbg">合同类型</td>
                        <td>${sessionScope.contract.type_contract}</td>
                    </tr>
                    <tr>
                        <td class="tdbg">合同总金额</td>
                        <td>${sessionScope.contract.total_contract_amount}</td>
                    </tr>
                    <tr>
                        <td class="tdbg">合同开始日期</td>
                        <td>${sessionScope.contract.date_start}</td>
                    </tr>
                    <tr>
                        <td class="tdbg">合同结束日期</td>
                        <td>${sessionScope.contract.date_end}</td>
                    </tr>
                    <%
                        Long num = null;
                        Contract contract = (Contract) request.getSession().getAttribute("contract");
                        DateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
                        try {
                            if (contract != null) {
                                Date star = dft.parse(contract.getDate_start());//开始时间
                                Date endDay = dft.parse(contract.getDate_end());//结束时间
                                Long starTime = star.getTime();
                                Long endTime = endDay.getTime();
                                num = endTime - starTime;//时间戳相差的毫秒数
                                num = num / 24 / 60 / 60 / 1000;//除以一天的毫秒数
                            }
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                    %>
                    <tr>
                        <td class="tdbg">时长</td>
                        <td><%=num%>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdbg">宿舍单价</td>
                        <td>${sessionScope.contract.price}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">合同应收金额（含税）</td>
                        <td>${sessionScope.contract.receivable_amount}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">合同签订日期</td>
                        <td>${sessionScope.contract.award_datetime}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">合同状态</td>
                        <td>${sessionScope.contract.contract_status}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">入行时间</td>
                        <td>${sessionScope.contract.entry_datetime}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">合同终止日期</td>
                        <td>${sessionScope.contract.termination_datetime}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">终止原因</td>
                        <td>${sessionScope.contract.termination_reason}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">终止人</td>
                        <td>${sessionScope.contract.termination_people}</td>
                    </tr>

                    <tr>
                        <td style="width: 200px;">单位盖章:</td>
                        <td>负责人签字:</td>
                        <td>时间:</td>
                    </tr>

                </table>
                <button class="btn btn-primary">打印</button>
            </div>
        </c:if>

        <c:if test="${not empty sessionScope.repair}">
            <div style="display: block;margin-bottom: 50px;" id="repairOrder">
                <table class="table table-bordered table-hover">
                    <h4>维修费用清单</h4>

                    <tr>
                        <td class="tdbg">费用清单编号</td><!--id: id-->
                        <td id="id">${sessionScope.repair.id}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">员工号</td><!--id: userId-->
                        <td>${sessionScope.repair.userId}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">维修项目</td><!--id: repair_project-->
                        <td>${sessionScope.repair.repair_project}</td>
                    </tr>

                    <tr>
                        <td class="tdbg">维修费用</td><!--id: maintenanceCosts-->
                        <td>
                            <c:if test="${sessionScope.repair.maintenanceCosts!=-1}">
                                ${sessionScope.repair.maintenanceCosts}
                            </c:if>
                            <c:if test="${sessionScope.repair.maintenanceCosts==-1}">
                                费用结算中
                            </c:if>
                        </td>
                    </tr>

                    <tr>
                        <td class="tdbg">已收款金额</td>
                        <td>${sessionScope.repair.feesPaid}
                            <button id="payment2" type="button" class="btn" style="display: none;"
                                    data-toggle="popover">继续付款
                            </button>
                        </td>
                    </tr>

                    <tr>
                        <td class="tdbg">扣款状态</td>
                        <td>
                            <c:if test="${sessionScope.repair.deductionStatus==0}">
                                未付款
                            </c:if>
                            <c:if test="${sessionScope.repair.deductionStatus==1}">
                                已付款
                            </c:if>
                        </td>
                    </tr>

                    <tr>
                        <td class="tdbg">备注</td>
                        <td>${sessionScope.repair.description}</td>
                    </tr>
                    <tr>
                        <td style="width: 200px;">单位盖章:</td>
                        <td>负责人签字:</td>
                        <td>时间:</td>
                    </tr>

                </table>
                <button class="btn btn-primary">打印</button>
            </div>
        </c:if>

    </div>
</div>

<div class="modal fade" id="Modal">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="modalTitle">是否退出登录</h5>
                <button type="button" class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <a class="btn btn-primary" href="login01.html" style="color:white">确定</a>
            </div>
        </div>
    </div>
</div>

</body>

<script type="text/javascript">
    //返回顶部
    $(function () {
        $("#side-bar .gotop").click(function () {
            $('html,body').animate({
                'scrollTop': 0
            }, 500);
        });
    })


</script>
<script>
    $(function () {
        $('[data-toggle="popover"]').popover({
            animation: true,                                 //应用CSS淡入淡出过渡特效
            html: true,                                     //支持HTML字符串
            offset: "200px",                                 //设置偏移位置
            title: "微信支付",                           //显示标题
            content: "<img src='../../static/images/payment.png' class='img-fluid' >",     //显示内容
            trigger: "click",                                 //鼠标单击时触发
            delay: {show: 100, hide: 100},                      //显示和延迟的时间

        });
    })
</script>

</html>